package dataStructure.xmg2.a01;

/**
 * @author: vince_zww
 * @date: 2022/1/9 10:49
 * @desceription:
 */
public class SelectionSort extends Sort {


    @Override
    protected void sort() {
        for (int end = array.length - 1; end > 0; end--) {
            int maxIndex = 0;
            for (int begin = 1; begin <= end; begin++) {
                //if (array[maxIndex] <= array[begin]) {
                if (cmp(maxIndex, begin) <= 0) {
                    maxIndex = begin;
                }
            }
            swap(maxIndex,end);
        }
    }


}
